package com.soma.game.controller;

import com.soma.game.entity.User;
import com.soma.game.entity.UserExample;
import com.soma.game.model.ResEnv;
import com.soma.game.service.UserService;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: soma-game
 * @description: 用户接口
 * @author: hduprince
 * @create: 2018-07-17 15:37
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    Logger logger = LoggerFactory.getLogger(UserController.class);

    @Resource
    private UserService userService;

    @RequestMapping("getList")
    public ResEnv getUserList(){
        try {
            List<User> list = userService.selectByExample(new UserExample());
            return ResEnv.success(list);
        } catch (Exception e){
            logger.error("操作失败， {}", ExceptionUtils.getStackTrace(e));
            return ResEnv.fail("操作失败, " + e.getMessage());
        }
    }
}
